package bishi.kaizi;

import java.util.Scanner;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2022/03/05 16:48
 */
public class _02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[][] nums = new int[10][10];
        for (int i=0;i<K;i++){
            int x=sc.nextInt();
            int y=sc.nextInt();
            nums[x][y] = sc.nextInt();
        }
        for(int i=M-1;i>=0;i--){
            for(int j=N-1;j>=0;j--){
                nums[i][j] = nums[i][j] + Math.max(i==M-1?0:nums[i+1][j],j==N-1?0:nums[i][j+1]);
            }
        }
        System.out.println(nums[0][1]+nums[1][0]);
    }
}
